Change in openvpn[master]: port-share: Check return value of fork()
A message that is not in the archive (sent off-list or not yet received): gerrit.1768318939000.I5eac1b31ae40eb957e2c12ca6c37b491fef32847@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email
to review the following change.
Change subject: port-share: Check return value of fork()
......................................................................
port-share: Check return value of fork()
While here, do some small C11 code cleanup.
Github: openvpn-private-issues#12
---
M src/openvpn/ps.c
1 file changed, 18 insertions(+), 16 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/1470/1
src/openvpn/ps.c +18 -16
@@ -800,12 +800,9 @@ port_share_open(const char *host, const char *port, const int max_initial_buf, const char *journal_dir) { - pid_t pid; socket_descriptor_t fd[2];struct openvpn_sockaddr hostaddr;struct port_share *ps; -int status; -struct addrinfo *ai; ALLOC_OBJ_CLEAR(ps, struct port_share); ps->foreground_fd =-1 ;
@@ -814,13 +811,15 @@/* * Get host's IP address */ - - status = -openvpn_getaddrinfo (GETADDR_RESOLVE |GETADDR_FATAL , host, port,0 ,NULL ,AF_UNSPEC , &ai); -ASSERT (status ==0 ); -ASSERT (sizeof (hostaddr.addr) >= ai->ai_addrlen); -memcpy (&hostaddr.addr.sa, ai->ai_addr, ai->ai_addrlen); -freeaddrinfo (ai); + { +struct addrinfo *ai; +int status = +openvpn_getaddrinfo (GETADDR_RESOLVE |GETADDR_FATAL , host, port,0 ,NULL ,AF_UNSPEC , &ai); +ASSERT (status ==0 ); +ASSERT (sizeof (hostaddr.addr) >= ai->ai_addrlen); +memcpy (&hostaddr.addr.sa, ai->ai_addr, ai->ai_addrlen); +freeaddrinfo (ai); + }if (msg_test (D_PS_PROXY_DEBUG )) {
@@ -836,19 +835,22 @@*/ if (socketpair (PF_UNIX ,SOCK_DGRAM ,0 , fd) ==-1 ) { -msg (M_WARN ,"PORT SHARE: socketpair call failed" ); +msg (M_WARN |M_ERRNO ,"PORT SHARE: socketpair call failed" ); goto error; }/* * Fork off background proxy process. */ - pid =fork (); +pid_t pid =fork (); -if (pid) +if (pid <0 ) { -int status; - +msg (M_WARN |M_ERRNO ,"PORT SHARE: fork failed" ); + goto error; + } +else if (pid) + {/* * Foreground Process */
@@ -862,7 +864,7 @@set_cloexec (fd[0 ]);/* wait for background child process to initialize */ - status =recv_control (fd[0 ]); +int status =recv_control (fd[0 ]);if (status ==RESPONSE_INIT_SUCCEEDED ) {/* note that this will cause possible EAGAIN when writing to
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5eac1b31ae40eb957e2c12ca6c37b491fef32847
Gerrit-Change-Number: 1470
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email )
Change subject: port-share: Check return value of fork()
......................................................................
Patch Set 1: Code-Review-1
(1 comment)
File src/openvpn/ps.c:
http://gerrit.openvpn.net/c/openvpn/+/1470/comment/15ae06d2_c91866a0?usp=email :
PS1, Line 814: {
why this extra bracket level? To ensure scoping for "status"? Not sure I find this a good change... since we try to get rid of these constructs elsewhere it's confusing me, at least.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5eac1b31ae40eb957e2c12ca6c37b491fef32847
Gerrit-Change-Number: 1470
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 15 Jan 2026 09:28:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: cron2, flichtenheld, plaisthos.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: port-share: Check return value of fork()
......................................................................
port-share: Check return value of fork()
While here, do some small C11 code cleanup.
Github: openvpn-private-issues#12
---
M src/openvpn/ps.c
1 file changed, 12 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/1470/2
src/openvpn/ps.c +12 -12
@@ -800,12 +800,9 @@ port_share_open(const char *host, const char *port, const int max_initial_buf, const char *journal_dir) { - pid_t pid; socket_descriptor_t fd[2];struct openvpn_sockaddr hostaddr;struct port_share *ps; -int status; -struct addrinfo *ai; ALLOC_OBJ_CLEAR(ps, struct port_share); ps->foreground_fd =-1 ;
@@ -814,9 +811,9 @@/* * Get host's IP address */ - - status = -openvpn_getaddrinfo (GETADDR_RESOLVE |GETADDR_FATAL , host, port,0 ,NULL ,AF_UNSPEC , &ai); +struct addrinfo *ai; +int status =openvpn_getaddrinfo (GETADDR_RESOLVE |GETADDR_FATAL , host, port, +0 ,NULL ,AF_UNSPEC , &ai);ASSERT (status ==0 );ASSERT (sizeof (hostaddr.addr) >= ai->ai_addrlen);memcpy (&hostaddr.addr.sa, ai->ai_addr, ai->ai_addrlen);
@@ -836,19 +833,22 @@*/ if (socketpair (PF_UNIX ,SOCK_DGRAM ,0 , fd) ==-1 ) { -msg (M_WARN ,"PORT SHARE: socketpair call failed" ); +msg (M_WARN |M_ERRNO ,"PORT SHARE: socketpair call failed" ); goto error; }/* * Fork off background proxy process. */ - pid =fork (); +pid_t pid =fork (); -if (pid) +if (pid <0 ) { -int status; - +msg (M_WARN |M_ERRNO ,"PORT SHARE: fork failed" ); + goto error; + } +else if (pid) + {/* * Foreground Process */
@@ -862,7 +862,7 @@set_cloexec (fd[0 ]);/* wait for background child process to initialize */ - status =recv_control (fd[0 ]); +int status =recv_control (fd[0 ]);if (status ==RESPONSE_INIT_SUCCEEDED ) {/* note that this will cause possible EAGAIN when writing to
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5eac1b31ae40eb957e2c12ca6c37b491fef32847
Gerrit-Change-Number: 1470
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Attention is currently required from: cron2, plaisthos.
flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email )
Change subject: port-share: Check return value of fork()
......................................................................
Patch Set 2:
(1 comment)
File src/openvpn/ps.c:
http://gerrit.openvpn.net/c/openvpn/+/1470/comment/f8106373_61c2191a?usp=email :
PS1, Line 814: {
Quoted 1 line
why this extra bracket level? To ensure scoping for "status"? Not sure I find this a good change.. […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5eac1b31ae40eb957e2c12ca6c37b491fef32847
Gerrit-Change-Number: 1470
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Fri, 16 Jan 2026 14:05:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email )
Change subject: port-share: Check return value of fork()
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5eac1b31ae40eb957e2c12ca6c37b491fef32847
Gerrit-Change-Number: 1470
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 19 Jan 2026 17:11:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH v2 1/1 port-share: Check return value of fork()
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
While here, do some small C11 code cleanup.
Github: openvpn-private-issues#12
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1470
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1470
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/ps.c +12 -12
@@ -800,12 +800,9 @@ port_share_open(const char *host, const char *port, const int max_initial_buf, const char *journal_dir) { - pid_t pid; socket_descriptor_t fd[2];struct openvpn_sockaddr hostaddr;struct port_share *ps; -int status; -struct addrinfo *ai; ALLOC_OBJ_CLEAR(ps, struct port_share); ps->foreground_fd =-1 ;
@@ -814,9 +811,9 @@/* * Get host's IP address */ - - status = -openvpn_getaddrinfo (GETADDR_RESOLVE |GETADDR_FATAL , host, port,0 ,NULL ,AF_UNSPEC , &ai); +struct addrinfo *ai; +int status =openvpn_getaddrinfo (GETADDR_RESOLVE |GETADDR_FATAL , host, port, +0 ,NULL ,AF_UNSPEC , &ai);ASSERT (status ==0 );ASSERT (sizeof (hostaddr.addr) >= ai->ai_addrlen);memcpy (&hostaddr.addr.sa, ai->ai_addr, ai->ai_addrlen);
@@ -836,19 +833,22 @@*/ if (socketpair (PF_UNIX ,SOCK_DGRAM ,0 , fd) ==-1 ) { -msg (M_WARN ,"PORT SHARE: socketpair call failed" ); +msg (M_WARN |M_ERRNO ,"PORT SHARE: socketpair call failed" ); goto error; }/* * Fork off background proxy process. */ - pid =fork (); +pid_t pid =fork (); -if (pid) +if (pid <0 ) { -int status; - +msg (M_WARN |M_ERRNO ,"PORT SHARE: fork failed" ); + goto error; + } +else if (pid) + {/* * Foreground Process */
@@ -862,7 +862,7 @@set_cloexec (fd[0 ]);/* wait for background child process to initialize */ - status =recv_control (fd[0 ]); +int status =recv_control (fd[0 ]);if (status ==RESPONSE_INIT_SUCCEEDED ) {/* note that this will cause possible EAGAIN when writing to
[Openvpn-devel] [PATCH applied] Re: port-share: Check return value of fork()
Change looks good. C11 cleanup generally helps make the code more readable, and error handling is a useful thing :-) - even though it's hard to trigger that error. I do run a --port-share server test instance, and it still passes :-)
Your patch has been applied to the master branch.
commit 1a31efb4950a48913e1a79dc948c6a173d744fb7
Author: Frank Lichtenheld Date: Mon Jan 19 18:12:11 2026 +0100
port-share: Check return value of fork()
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1470
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35337.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email )
Change subject: port-share: Check return value of fork()
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5eac1b31ae40eb957e2c12ca6c37b491fef32847
Gerrit-Change-Number: 1470
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 22 Jan 2026 12:46:22 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
cron2 has uploaded a new patch set (#3) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2, Code-Review+2 by plaisthos
Change subject: port-share: Check return value of fork()
......................................................................
port-share: Check return value of fork()
While here, do some small C11 code cleanup.
Github: openvpn-private-issues#12
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1470
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35337.html
---
M src/openvpn/ps.c
1 file changed, 12 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/1470/3
src/openvpn/ps.c +12 -12
@@ -800,12 +800,9 @@ port_share_open(const char *host, const char *port, const int max_initial_buf, const char *journal_dir) { - pid_t pid; socket_descriptor_t fd[2];struct openvpn_sockaddr hostaddr;struct port_share *ps; -int status; -struct addrinfo *ai; ALLOC_OBJ_CLEAR(ps, struct port_share); ps->foreground_fd =-1 ;
@@ -814,9 +811,9 @@/* * Get host's IP address */ - - status = -openvpn_getaddrinfo (GETADDR_RESOLVE |GETADDR_FATAL , host, port,0 ,NULL ,AF_UNSPEC , &ai); +struct addrinfo *ai; +int status =openvpn_getaddrinfo (GETADDR_RESOLVE |GETADDR_FATAL , host, port, +0 ,NULL ,AF_UNSPEC , &ai);ASSERT (status ==0 );ASSERT (sizeof (hostaddr.addr) >= ai->ai_addrlen);memcpy (&hostaddr.addr.sa, ai->ai_addr, ai->ai_addrlen);
@@ -836,19 +833,22 @@*/ if (socketpair (PF_UNIX ,SOCK_DGRAM ,0 , fd) ==-1 ) { -msg (M_WARN ,"PORT SHARE: socketpair call failed" ); +msg (M_WARN |M_ERRNO ,"PORT SHARE: socketpair call failed" ); goto error; }/* * Fork off background proxy process. */ - pid =fork (); +pid_t pid =fork (); -if (pid) +if (pid <0 ) { -int status; - +msg (M_WARN |M_ERRNO ,"PORT SHARE: fork failed" ); + goto error; + } +else if (pid) + {/* * Foreground Process */
@@ -862,7 +862,7 @@set_cloexec (fd[0 ]);/* wait for background child process to initialize */ - status =recv_control (fd[0 ]); +int status =recv_control (fd[0 ]);if (status ==RESPONSE_INIT_SUCCEEDED ) {/* note that this will cause possible EAGAIN when writing to
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5eac1b31ae40eb957e2c12ca6c37b491fef32847
Gerrit-Change-Number: 1470
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email )
Change subject: port-share: Check return value of fork()
......................................................................
port-share: Check return value of fork()
While here, do some small C11 code cleanup.
Github: openvpn-private-issues#12
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1470
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35337.html
---
M src/openvpn/ps.c
1 file changed, 12 insertions(+), 12 deletions(-)
src/openvpn/ps.c +12 -12
@@ -800,12 +800,9 @@ port_share_open(const char *host, const char *port, const int max_initial_buf, const char *journal_dir) { - pid_t pid; socket_descriptor_t fd[2];struct openvpn_sockaddr hostaddr;struct port_share *ps; -int status; -struct addrinfo *ai; ALLOC_OBJ_CLEAR(ps, struct port_share); ps->foreground_fd =-1 ;
@@ -814,9 +811,9 @@/* * Get host's IP address */ - - status = -openvpn_getaddrinfo (GETADDR_RESOLVE |GETADDR_FATAL , host, port,0 ,NULL ,AF_UNSPEC , &ai); +struct addrinfo *ai; +int status =openvpn_getaddrinfo (GETADDR_RESOLVE |GETADDR_FATAL , host, port, +0 ,NULL ,AF_UNSPEC , &ai);ASSERT (status ==0 );ASSERT (sizeof (hostaddr.addr) >= ai->ai_addrlen);memcpy (&hostaddr.addr.sa, ai->ai_addr, ai->ai_addrlen);
@@ -836,19 +833,22 @@*/ if (socketpair (PF_UNIX ,SOCK_DGRAM ,0 , fd) ==-1 ) { -msg (M_WARN ,"PORT SHARE: socketpair call failed" ); +msg (M_WARN |M_ERRNO ,"PORT SHARE: socketpair call failed" ); goto error; }/* * Fork off background proxy process. */ - pid =fork (); +pid_t pid =fork (); -if (pid) +if (pid <0 ) { -int status; - +msg (M_WARN |M_ERRNO ,"PORT SHARE: fork failed" ); + goto error; + } +else if (pid) + {/* * Foreground Process */
@@ -862,7 +862,7 @@set_cloexec (fd[0 ]);/* wait for background child process to initialize */ - status =recv_control (fd[0 ]); +int status =recv_control (fd[0 ]);if (status ==RESPONSE_INIT_SUCCEEDED ) {/* note that this will cause possible EAGAIN when writing to
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5eac1b31ae40eb957e2c12ca6c37b491fef32847
Gerrit-Change-Number: 1470
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>